﻿using System;
using UnityEngine;
using System.Collections;
namespace SGUI
{
    public static class SGTools
    {
        public static Color ColorFromHTML(string strcolor)
        {
            string tcolor = strcolor.TrimStart('#');
            int r = Convert.ToInt16("0x" + tcolor.Substring(0, 2).ToString(), 16);
            int g = Convert.ToInt16("0x" + tcolor.Substring(2, 2).ToString(), 16);
            int b = Convert.ToInt16("0x" + tcolor.Substring(4, 2).ToString(), 16);
            Color col = new Color(r / 255f, g / 255f, b / 255f);
            return col;
        }

        public static double[] StringToNumberArr(string str) 
        {
            string[] arr = str.Split(',');
            double[] retNumberArr = new double[arr.Length];
            for (int i = 0; i < arr.Length;i++)
            {
                double outNumber = 0;
                double.TryParse(arr[i],out outNumber);
                retNumberArr[i] = outNumber;
            }
            return retNumberArr;
        }


    }
}
